<include file="Public:header" />
<include file="nav" />
<div class="listbox">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
    <thead>
        <tr>
            <th width="200">备份名称</th>
            <th width="80">卷数</th>
            <th width="80">压缩</th>
            <th width="80">数据大小</th>
            <th width="200">备份时间</th>
            <th>状态</th>
            <th width="200">操作</th>
        </tr>
    </thead>
    <tbody>
        <volist name="list" id="data">
            <tr>
                <td align="center">{$data.time|date='Ymd-His',###}</td>
                <td align="center">{$data.part}</td>
                <td align="center">{$data.compress}</td>
                <td align="center">{$data.size|formatBytes}</td>
                <td align="center">{$key}</td>
                <td align="center">-</td>
                <td align="center" class="action">
                    <a href="{$data.file_path}">下载</a>&nbsp;|&nbsp;<a class="db-import" href="{:U('import?time='.$data['time'])}">还原</a>&nbsp;|&nbsp;<a onclick="return confirm('确定删除?')" href="{:U('del?time='.$data['time'])}">删除</a></td>
            </tr>
        </volist>
    </tbody>
</table>
</div>
<script type="text/javascript">
        $(".db-import").click(function(){
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "正在还原数据库，请不要关闭！" }
            return false;
        
            function success(data){
                if(data.status){
                    if(data.gz){
                        data.info += status;
                        if(status.length === 5){
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.info);
                    if(data.part){
                        $.get(self.href, 
                            {"part" : data.part, "start" : data.start}, 
                            success, 
                            "json"
                        );
                    }  else {
                        window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    alert(data.info);
                }
            }
        });
    </script>
<include file="Public:footer" />